<?php
namespace PsiFramework\Applications\DefaultApp\Classes\Actions\User;

import("Classes.Actions.AbstractAction");
import("Classes.Util.Object.Identification");

use \PsiFramework\Classes\Actions\AbstractAction;
use \PsiFramework\Classes\Util\Object\Identification;

/**
 * PsiFramework
 * Php Simple Framework
 *
 * @author Rémi San
 * @version beta
 */

/**
 * The Login Action
 *
 * This action is used when a user wants to access the login form
 *
 * @package Actions.User
 */
class LoginAction extends AbstractAction
{

    /**
     * Function executed by the controller
     *
     * It shows the login form page
     *
     * @return Response    the response to the action execution
     */
    public function execute(/*Identification*/ $identification=null)
    {
        parent::execute();

        if ($identification==null) {
            $login = $this->_request->getParameter('login');
            $error = $this->_request->getParameter('error');
            if ($login !== null && $error !== null) {
                $identification = new Identification($login, null, $error);
            }
        }

        $redirect = $this->_request->getParameter('redirect');

        $this->_response->setAttribute("identification", $identification);
        $this->_response->setAttribute("redirect", $redirect);

        $this->findForward("success");
    }
}
